<?php
!function_exists('adminmsg') && exit('Forbidden');
InitGP(array('hid'),'2');
empty($hid) && adminmsg('undefined_action');
InitGP(array('type'));
$_basename	= $basename.'&action=video&hid='.$hid;
$videoService = House::loadClass('video'); /* @var $videoService PW_Video */
if (!$type) {
	InitGP(array('page'),'',2);
	!$page && $page =1;
	$videos = $videoService->getVideos($hid,$page);
	$pages = $videoService->getPages($hid,$_basename.'&',$page);
	$ajax_basename = EncodeUrl($_basename);
	require_once PrintMode('video');
} elseif ($type=='add') {
	InitGP(array('step'),'',2);
	define('AJAX', 1);
	if ($step==2) {
		InitGP(array('descrip'));
		$address = GetGP('address');
		$videoService->addVideo($hid,array('descrip'=>$descrip,'address'=>$address,'creator'=>$admin_name));
		echo getLangInfo('msg','operate_success')."\treload";
	} else {
		$ajax_basename = EncodeUrl($_basename);
		require_once PrintMode('ajax_video');
	}
	ajax_footer();
} elseif ($type=='edit') {
	define('AJAX', 1);
	InitGP(array('step','id'));
	if ($step == 2) {
		InitGP(array('descrip'));
		$address = GetGP('address');
		$videoService->updateVideo($id,array('address'=>$address,'descrip'=>$descrip,'creator'=>$admin_name));
		echo getLangInfo('msg','operate_success')."\treload";
	} else {
		$ajax_basename = EncodeUrl($_basename);
		$video = $videoService->getVideo($id);
		require_once PrintMode('ajax_video');
	}
	ajax_footer();
} elseif ($type=='delete') {
	define('AJAX', 1);
	InitGP(array('id'));
	$videoService->deleteVideo($id);
	echo 'success';
	ajax_footer();
} elseif ($type=='deletevideos') {
	InitGP(array('select'));
	if (!$select) {
		adminmsg('请选择要删除的图片',$_basename);
	}
	$videoService->deleteVideos($select);
	adminmsg('operate_success',$_basename);
}
?>